# -*- coding:utf-8 -*-
"""
在Daily_A_Stocks_List中提取所有曾经出现过的股票信息
"""
import os

file_path = "../../../Daily_A_Stocks_List"
output_path = "../data/stockList.csv"

stock_list = set()
for file in os.listdir(file_path):
    if len(file) == 12 and file[-3:] == 'csv':
        today_file_path = os.path.join(file_path, file)
        with open(today_file_path, 'r', encoding='utf-8') as f:
            for each in f.readlines():
                stock_list.add(each.strip())

stock_list = sorted(list(stock_list))
with open(output_path, 'w', encoding='utf-8') as f:
    for stock in stock_list:
        f.write("%s\n" % stock)
